
//

#import "MainTabBarViewController.h"

#import "BaseViewController.h"
#import "MainNaviController.h"

#define kBarVCs @[@"HomeViewController",@"ClassViewController",@"GroundViewController",@"MemberCenterViewController"]
#define kBarImgs @[@[@"tabbar_home",@"tabbar_home_selected"],@[@"tabbar_message_center",@"tabbar_message_center_selected"],@[@"tabbar_discover",@"tabbar_discover_selected"],@[@"tabbar_music",@"tabbar_music_selected"]]

@interface MainTabBarViewController ()

@end

@implementation MainTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self childrenCreat];
    
    [self.tabBar setBackgroundImage:[UIImage new]];
    [self.tabBar setShadowImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"cccccc" alpha:.5]]];
}

-(void)childrenCreat{
    
    for (NSInteger i=0; i < kBarVCs.count; i++) {
        
        Class BaseClass = NSClassFromString(kBarVCs[i]);
        
        BaseViewController *baseVC = [BaseClass new];
        
        baseVC.naviStand.title = kBarVCs[i];
        
        //设置文本
        baseVC.tabBarItem.title = [kBarVCs[i] stringByReplacingOccurrencesOfString:@"ViewController" withString:@""];
        //设置默认图标
        baseVC.tabBarItem.image = [UIImage imageNamed:kBarImgs[i][0]];
        //设置tabBar
        self.tabBar.tintColor = naviColor;
        //设置选中图标
        baseVC.tabBarItem.selectedImage = [UIImage imageNamed:kBarImgs[i][1]];
        
        MainNaviController *naviVC=[[MainNaviController alloc]initWithRootViewController:baseVC];
        
        [self addChildViewController:naviVC];
    }
}

@end
